home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1191 / 1191.xpi / chrome / reminderfox.jar / content / reminderfox / mail / rmFxPopupControl.js < prev    next >
Text File  |  2009-12-04  |  7KB  |  178 lines

  1.  
  2.  
  3.    /**
  4.     *  Control the different menu-popups for Thunderbird/Mailapp
  5.     *  for References, Reminders and ICS-attachements
  6.     *  
  7.     *  @param thisId    indicates the 'source' or the id of the menu called from:
  8. <ul>
  9. <br>    'List'   - attachmentListContext  
  10. <br>    'Thread' - threadPaneContext
  11. <br>    'Msg'    - messagePaneContext
  12. </ul>
  13.     */
  14. function rmFxPopupCheck(thisId){
  15.     
  16.     var mailRm_AddReminder = document.getElementById("mailRm_AddReminder");
  17.     var mailRm_Open_Msg = document.getElementById("mailRm_Open_Msg");
  18.     var mailRm_ICS_Msg = document.getElementById("mailRm_ICS_Msg");
  19.     var mailRm_Open_Thread = document.getElementById("mailRm_Open_Thread");
  20.     var mailRm_thread_AddReminder = document.getElementById("mailRm_thread_AddReminder");
  21.     var mailRm_ICS_List = document.getElementById("mailRm_ICS_List");
  22.     var mailRm_addContact = document.getElementById("mailRm_addContact");
  23.     var mailRm_copyContact = document.getElementById("mailRm_copyContact");
  24.     var mailRM_sep1 = document.getElementById("mailRM_sep1");
  25.     var mailRM_sep2 = document.getElementById("mailRM_sep2");
  26.     var mailRM_sep3 = document.getElementById("mailRM_sep3");
  27.     
  28.     
  29.     var contextMenusEnabled = true;            
  30.     try {
  31.         contextMenusEnabled = reminderFox_prefs.getBoolPref(REMINDER_FOX_PREF + "." + REMINDER_FOX_ENABLE_CONTEXT_MENUS);
  32.     } catch(e) {
  33.     }            
  34.     
  35.     // user doesn't want context menus; hide them
  36.     if (!contextMenusEnabled ) {
  37.         if (mailRm_AddReminder != null  )
  38.             mailRm_AddReminder.hidden =true;
  39.         if (mailRm_Open_Msg != null  )
  40.            mailRm_Open_Msg.hidden = true;
  41.        if (mailRm_ICS_Msg != null  )
  42.            mailRm_ICS_Msg.hidden = true;
  43.        if (mailRm_Open_Thread != null  )
  44.            mailRm_Open_Thread.hidden = true;
  45.        if (mailRm_thread_AddReminder != null  )
  46.            mailRm_thread_AddReminder.hidden = true;
  47.        if (mailRm_ICS_List != null  )
  48.            mailRm_ICS_List.hidden = true;
  49.        if (mailRm_addContact != null  )
  50.            mailRm_addContact.hidden = true;
  51.        if (mailRm_copyContact != null  )
  52.            mailRm_copyContact.hidden = true;
  53.        if (mailRM_sep1 != null  )
  54.            mailRM_sep1.hidden = true;
  55.        if (mailRM_sep2 != null  )
  56.            mailRM_sep2.hidden = true;              
  57.        if (mailRM_sep3 != null  )
  58.            mailRM_sep3.hidden = true;                                
  59.         return;
  60.     }
  61.     
  62.         if (mailRm_AddReminder != null  )
  63.             mailRm_AddReminder.hidden =false;
  64.         if (mailRm_Open_Msg != null  )
  65.            mailRm_Open_Msg.hidden = false;
  66.        if (mailRm_ICS_Msg != null  )
  67.            mailRm_ICS_Msg.hidden = false;
  68.        if (mailRm_Open_Thread != null  )
  69.            mailRm_Open_Thread.hidden = false;
  70.        if (mailRm_thread_AddReminder != null  )
  71.            mailRm_thread_AddReminder.hidden = false;
  72.        if (mailRm_ICS_List != null  )
  73.            mailRm_ICS_List.hidden = false;
  74.        if (mailRm_addContact != null  )
  75.            mailRm_addContact.hidden = false;
  76.        if (mailRm_copyContact != null  )
  77.            mailRm_copyContact.hidden = false;
  78.        if (mailRM_sep1 != null  )
  79.            mailRM_sep1.hidden = false;
  80.        if (mailRM_sep2 != null  )
  81.            mailRM_sep2.hidden = false;              
  82.        if (mailRM_sep3 != null  )
  83.            mailRM_sep3.hidden = false;                                             
  84.  
  85.     var dMode = true;
  86.  
  87.     if (thisId.originalTarget.id == "threadPaneContext")         { var xulId = "Thread";}
  88.     if (thisId.originalTarget.id == "messagePaneContext")         { var xulId = "Msg";}
  89.     if (thisId.originalTarget.id == "attachmentListContext")     { var xulId = "List";}
  90.  
  91. // for TB3/SM2
  92.     if (thisId.originalTarget.id == "mailContext")                 { var xulId = "Msg";}
  93.  
  94. // for Postbox
  95.     if (thisId.originalTarget.id == "dataPaneAttachmentContextMenu") { var xulId = "List";}
  96.  
  97.     if ((xulId == "Msg") || (xulId == "List") || (xulId == "data")) {
  98.     // ----  check 'attachment(s)' for ICS reminders  ----
  99.     
  100.         if (currentAttachments.length > 0) { 
  101.             var i=0;
  102.             while (i < currentAttachments.length) {    
  103.                 var xx =currentAttachments[i].contentType.toLowerCase();    
  104.                 if ((xx == "text/calendar")     /* 'normal apps */                    
  105.                  || (xx == "application/ics") /* Google Calendar */     
  106.                     ) {dMode = false;}
  107.         /*
  108.         0001: currentAttachments[1].contentType = [string] "application/octet-stream"
  109.         0001: currentAttachments[1].displayName = [string] "c124447.ics"
  110.         */
  111.                 if ((xx == "application/octet-stream") 
  112.                  && (currentAttachments[i].displayName.toLowerCase().search(".ics")>-1 )) {
  113.                     {dMode = false;}
  114.                 }                    
  115.                 i++;
  116.             }        
  117.         }    
  118.         if (dMode == false) {
  119.             document.getElementById("mailRm_ICS_" +xulId).removeAttribute("disabled");
  120.         } else {
  121.             document.getElementById("mailRm_ICS_" +xulId).setAttribute("disabled", "true");            
  122.         }
  123.     }
  124.     
  125.     if ((xulId == "Thread") || (xulId == "Msg")) {
  126.     // ---- check message for 'References' and/or 'reminder.Id'  ----         
  127.     
  128.         if (rmFxGetRmRef().length > 0) {
  129.             document.getElementById("mailRm_Open_" +xulId).removeAttribute("disabled");
  130.             rmFx_msgTAGing("Reminderfox", true, "#993399");
  131.         } else {
  132.             document.getElementById("mailRm_Open_" +xulId).setAttribute("disabled", "true");            
  133.         }                                      
  134.     }
  135. }
  136.  
  137. /**
  138.  *  Control the different menu-popups for 'addReminder list'
  139.  *  for Contacts     //gW_Contact
  140.  *  @since TB3/SM2 and it's TB/AB rework
  141.  *  
  142.  *  @param thisId    indicates the 'source' or the id of the menu called from
  143.  */
  144. function rmFxPopupCheckContact(event){ 
  145.     //need delay for todo/lists for disabling menu item -- not clear why :>  
  146.     setTimeout( rmFx_popupContactDelayed, 300, event );
  147.  }     
  148.      
  149. function rmFx_popupContactDelayed(event) {
  150.     
  151.     var pMode = false;
  152.     document.getElementById("treechildren-contextmenu-reminder-openABcard").setAttribute("hidden", "true");
  153.     document.getElementById("treechildren-contextmenu-todo-openABcard").setAttribute("hidden", "true");
  154.     
  155.     var selectedEvents;
  156.     if (event.originalTarget.id == "treechildren-contextmenu")  {
  157.         selectedEvents = getAllSelectedReminders();    // from 'reminder list' context menu
  158.     }
  159.     if (event.originalTarget.id == "todo-treechildren-contextmenu")  {
  160.         selectedEvents = getAllSelectedTodos();    // from 'reminder list' context menu
  161.     }
  162.     
  163. // rmFxUtil.dump2Console ("gWTEST: 'popupCheckContact'  # selectedEvents >>" + selectedEvents.length + "<<");    
  164.  
  165.     if (selectedEvents.length == 1) {
  166.         
  167.         if (selectedEvents[0].extraInfo != null) {
  168.             if (selectedEvents[0].extraInfo.indexOf("X-REMINDERFOX-CONTACT:") != -1) pMode = true;
  169.             
  170.             if ((pMode == true) && gRmFx_AB3) {
  171.                 document.getElementById("treechildren-contextmenu-reminder-openABcard").removeAttribute("hidden");
  172.                 document.getElementById("treechildren-contextmenu-todo-openABcard").removeAttribute("hidden");
  173.             }
  174.         }
  175.     }
  176. }
  177.  
  178.